import java.util.HashMap;
import java.util.HashSet;
import java.util.Objects;

/**
 * @Author 12629
 * @Date 2022/4/3 8:09
 * @Description：
 */
class Person {
    public String id;

    public Person(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                '}';
    }

    /**
     * 在下标底下 找哪个节点的key和我是一样的
     * @param o
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(id, person.id);
    }

    /**
     * 找节点的小标的
     * @return
     */
    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
public class TestDemo {


    public static void main(String[] args) {
        HashBuck2<Person,String> map = new HashBuck2<>();
        Person person1 = new Person("123456");
        Person person2 = new Person("123456");
        map.put(person1,"gaobo");

        System.out.println(map.get(person2));//gaobo
    }

    public static void main3(String[] args) {
        HashMap<Person,String> map = new HashMap<>();
        Person person1 = new Person("123456");
        Person person2 = new Person("123456");

        System.out.println(person1.hashCode());//找位置
        System.out.println(person2.hashCode());

        map.put(person1,"gaobo");

        System.out.println(map.get(person2));



    }



    public static void main2(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.put(1,1);
        hashBuck.put(2,2);
        hashBuck.put(3,3);
        hashBuck.put(6,6);
        hashBuck.put(14,14);// 14
        hashBuck.put(24,44);// 8
        System.out.println("hello");
    }

    public int firstUniqChar(String s) {
        int[] array = new int[26];
        for(int i = 0;i < s.length();i++) {
            char ch = s.charAt(i);
            array[ch-'a']++;
        }

        for(int i = 0;i < s.length();i++) {
            char ch = s.charAt(i);
            if(array[ch-'a'] == 1) {
                return i;
            }
        }
        return -1;
    }

}
